using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Plugin.MassSend.Scene;
using MicroMsg.Protocol;
using MicroMsg.Resource.@string;
using MicroMsg.Storage;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using System;
using System.IO.IsolatedStorage;
using System.Windows.Media.Imaging;
namespace MicroMsg.Plugin.MassSend
{
	public class MassSend : PluginBase
	{
		private const string TAG = "MassSend";
		public const string PluginKey = "plugin MassSend";
		public const long PluginID = 32770L;
		public const string PluginName = "MassSend";
		public const int PluginVersion = 256;
		private static MassSend mInstance;
		public NetSceneMassSend mSceneMassSend;
		public override string mTitle
		{
			get
			{
				return strings.Con_Plugin_MassSend_Nickname;
			}
		}
		public override BitmapSource mIcon
		{
			get
			{
				return ImageCacheMgr.loadFromRes("Source/Plugin/MassSend/Resource/Img/icon.png");
			}
		}
		public override BitmapSource mIconHD
		{
			get
			{
				return HeadImgMgr.getHeadImage("masssend", true);
			}
		}
		public override BitmapSource mIconInList
		{
			get
			{
				return this.mIcon;
			}
		}
		public override string mDescription
		{
			get
			{
				return strings.MassSend_Intro;
			}
		}
		public override string mAuthor
		{
			get
			{
				return "tencent";
			}
		}
		public MassSend()
		{
			this.mKey = "plugin MassSend";
			this.mID = 32770L;
			this.mName = "MassSend";
			this.mUserName = "masssend";
			this.mVersion = 256;
			this.mIndexInTab = MainTabIndex.ContactTab;
			this.mIndexInGroup = 2;
			this.mIndexInPosition = 0;
			this.mProtocolPluginFlag = EPluginFlag.MM_MASSSEND_UNINSTALL;
			this.mDefaultInstalled = true;
			MassSend.mInstance = this;
		}
		public override PluginSettingBaseCtrl GetPluginSettingCtrl()
		{
			return new MassSendPluginSetCtrl();
		}
		public static MassSend getInstance()
		{
			return MassSend.mInstance;
		}
		public override void onRegisterResult(RetConst retConst_0, int code)
		{
			Log.smethod_4("MassSend", string.Concat(new object[]
			{
				"on register result , ret = ",
				retConst_0,
				", code = ",
				code
			}));
		}
		public override bool onInitialize()
		{
			Log.smethod_4("MassSend", "initialize. ");
			this.mSceneMassSend = new NetSceneMassSend();
			using (IsolatedStorageFile userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication())
			{
				string pluginPath = StorageIO.getPluginPath("MassSend");
				string text = StorageIO.getPluginPath("MassSend") + "/image";
				string text2 = StorageIO.getPluginPath("MassSend") + "/voice";
				string text3 = StorageIO.getPluginPath("MassSend") + "/video";
				string text4 = StorageIO.getPluginPath("MassSend") + "/thumbnail";
				string text5 = StorageIO.getPluginPath("MassSend") + "/thumbVideo";
				if (!userStoreForApplication.DirectoryExists(pluginPath))
				{
					userStoreForApplication.CreateDirectory(pluginPath);
				}
				if (!userStoreForApplication.DirectoryExists(text))
				{
					userStoreForApplication.CreateDirectory(text);
				}
				if (!userStoreForApplication.DirectoryExists(text2))
				{
					userStoreForApplication.CreateDirectory(text2);
				}
				if (!userStoreForApplication.DirectoryExists(text3))
				{
					userStoreForApplication.CreateDirectory(text3);
				}
				if (!userStoreForApplication.DirectoryExists(text4))
				{
					userStoreForApplication.CreateDirectory(text4);
				}
				if (!userStoreForApplication.DirectoryExists(text5))
				{
					userStoreForApplication.CreateDirectory(text5);
				}
			}
			return true;
		}
		public override bool onInstalled(InstallMode mode)
		{
			Log.smethod_4("MassSend", "on inistalled. ");
			StorageMgr.contact.update(new Contact
			{
				strUsrName = this.mUserName,
				nFlags = 3u,
				nImgFlag = 3u
			});
			return true;
		}
		public override bool onUninstalled(InstallMode mode)
		{
			Log.smethod_4("MassSend", "on uninstalled. ");
			StorageMgr.contact.update(new Contact
			{
				strUsrName = this.mUserName,
				nFlags = 0u,
				nImgFlag = 3u
			});
			MassMsgMgr.MassMsgClearAll();
			return true;
		}
		public override void onAppActivated()
		{
		}
		public override void onAppDeactivated()
		{
		}
		public override object execute(int entryType, object args)
		{
			Log.smethod_4("MassSend", "plugin execute,   entrytype =" + entryType);
			if (entryType == 2)
			{
				ToolFunction.GotoPageForUserControl("/Source/Plugin/MassSend/UI/MessagesListPage.xaml", null, false);
			}
			return null;
		}
	}
}
